package ar.cpfw.hibernate.mapping.onetomany;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity(name = "Department")
@Table(name = "departments")
public class Department {
	@Id
	@Column(name = "id")
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	private String id;

	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "department_id")
	private Set<Employee> employees = new HashSet<Employee>();

	public Department() {

	}

	public void addEmployee(Employee m) {
		employees.add(m);
	}
	
	public Set<Employee> getEmployees() {
		return employees;
	}

	public void setEmployees(Set<Employee> malcolms) {
		this.employees = malcolms;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

}
